<?php
class Item_model extends MY_Model {
	
  	var $category_id = 0;
    var $name = null;
    var $code = null;
    var $price = 0;
    var $sku = null;
    var $description = null;
    var $available_qty = 0;
    
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

	function findByItemCode($itemCode) {
		$sql = "SELECT * FROM ".$this->table()." WHERE valid = ? AND code = ?";
		return $this->db->query($sql, array(1,$itemCode))->result_object();
	}
	
	public function findByItemCodeOfOthers($id, $itemCode) {
		$sql = "SELECT * FROM " . $this->table() . " WHERE valid = ? AND code = ? AND id != ?";
		return $this->db->query($sql, array(1,$itemCode,$id))->result_object();
	}
}	